<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<div>
  <h4 class="vertical-margin-10">保理合同信息</h4>
  
  <div class="panel panel-default">
    <div class="panel-body">
     
     <div class="row">
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>合同编号:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.contractNo}</p></div>
      
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>融资方:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.borrowerName}</p></div>
      
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>回款账户开户行:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.lenderAcBkName}</p></div>
      
     </div>
     
     <div class="row">
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>回款账户账号:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.lenderAcNo}</p></div>
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>准备金释放方式:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p><fmt:message key="${factoringContract.depositDeductType.key}" /></p></div>
      
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>手续费收取方式:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p><fmt:message key="${factoringContract.costDeductType.key}" /></p></div>
      
     </div>
     
     <div class="row">
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>扣息方式:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p><fmt:message key="${factoringContract.intAccuretype.key}" /></p></div>
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>融资比例:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p><fmt:formatNumber type="percent"  maxIntegerDigits="3" value="${factoringContract.advaPct}" /></p></div>
      
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>核销比例:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p><fmt:formatNumber type="percent"  maxIntegerDigits="3" value="${factoringContract.settlePct}" /></p></div>
      
     </div>
     
     <div class="row">
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>手续费率:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.arCostRate}%</p></div>
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>融资期限（日）:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.advaTerm}</p></div>
      
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>融资宽限期:</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p>${factoringContract.advaMatuterm}</p></div>
      
     </div>
     
     <div class="row">
     
      <div class="text-align-right col-xs-2 col-md-2"><p class="title"><strong>融资利率(年化):</strong></p></div>
      <div class="text-align-left col-xs-2 col-md-2"><p><fmt:formatNumber type="percent"  maxIntegerDigits="6" minFractionDigits="4" value="${factoringContract.nominalRate}" /></p></div>
      
     </div>
     
    </div>
    <div class="panel-footer">
    
      <table class="table table-striped demo2do-table bottom-margin-20 text-left settlement">
    
        <tr>
          <td>
            <p class="title"><strong>应收款总额</strong></p>
            <p>
               <fmt:formatNumber type="currency" value="${factoringContract.totalArAmt}" />
            </p>
          </td>
    
          <td>
            <p class="title"><strong>应收账款余额</strong></p>
            <p>
               <fmt:formatNumber type="currency" value="${factoringContract.totalArAmtAval}" />
            </p>
          </td>
        </tr>
    
        <tr>
          <td>
            <p class="title"><strong>融资本金（初始）</strong></p>
            <p>
               <fmt:formatNumber type="currency" value="${factoringContract.totalOtsdAmt}" />
            </p>
          </td>
        
          <td>
            <p class="title"><strong>融资余额</strong></p>
            <p>
               <fmt:formatNumber type="currency" value="${factoringContract.totalOtsdAmtAval}" />
            </p>
          </td>
        </tr>
    
        <tr>
          <td>
            <p class="title"><strong>风险准备金</strong></p>
            <p>
               <fmt:formatNumber type="currency" value="${factoringContract.totalDepositAmt}" /> 
            </p>
          </td>
          
          <td>
            <p class="title"><strong>本次核销后风险金余额</strong></p>
            <p>
                <fmt:formatNumber type="currency" value="${factoringContract.totalDepositAmtAval}" />
            </p>
          </td>
        </tr>
    
        <tr>
          <td>
            <p class="title"><strong>合同起始日</strong></p>
            <p><fmt:formatDate value="${factoringContract.advaStartDate}" pattern="yyyy/MM/dd" /></p>
          </td>
          
          <td>
            <p class="title"><strong>本次核销时间</strong></p>
            <p><fmt:formatDate value="${settlementDate}" pattern="yyyy/MM/dd HH:mm:SS" /></p>
          </td>
        </tr>
   
      </table>
      
    </div>
  </div>

  <h4 class="vertical-margin-10">本次核销明细</h4>
  
  <div class="detail table-warp table-responsive" style="overflow:auto">
  
	  <table class="table table-striped table-hover demo2do-table bottom-margin-20 text-left settlement">

	  	<tbody>

	  		<tr>
	  			<th>序号</th>
				<th>应收账款编号</th>
				<th>核销前融资余额(元)</th>
				<th style="max-width:150px;">租赁合同号/租客</th>
				<th>当期应还款日</th>
				<th>融资起始日</th>
				<th>实际到账日</th>
				<th style="min-width:45px;">计息天数</th>
				<th style="max-width:100px;">到账金额(元)</th>
			<%-- 	
				<th>手续费</th>
			--%>
				<th>利息(元)</th>
				<th style="max-width:100px;">本次还本金额(元)</th>
				<th style="max-width:35px;">尾款(元)</th>
			 	
				<th style="max-width:100px;">释放风险准备金</th>
            <%--
                <th>补充风险准备金</th>
			--%>
				<th>融资余额</th>
			</tr>
            <c:forEach var="settleItem" items="${settleItems}" varStatus="status">
    			<tr>
    				<td>${status.index + 1 }</td>
    				<td>${settleItem.financePaymentRecord.order.orderNo}</td>
    				<td>
    				    <fmt:formatNumber type="number" value="${settleItem.otsdAmtAvalPre}" />
    				</td>
    				<td style="max-width:150px;">${settleItem.financePaymentRecord.order.contract.contractNo}<br/>${settleItem.financePaymentRecord.order.customer.name}</td>
    				<td><fmt:formatDate value="${settleItem.financePaymentRecord.order.dueDate}" pattern="yyyy-MM-dd" /></td>
    				<td><fmt:formatDate value="${settleItem.settleDatePre}" pattern="yyyy-MM-dd" /></td>
    				<td><fmt:formatDate value="${settleItem.financePaymentRecord.order.payoutTime}" pattern="yyyy-MM-dd" /></td>
    				<td style="min-width:45px;">${settleItem.intDuration}</td>
    				<td style="max-width:100px;">
    				    <fmt:formatNumber type="number" value="${settleItem.financePaymentRecord.payMoney}" />
    				</td>
    			<%-- 	
    				<td>${settleItem.arCost}</td>
    			--%>
    				<td>
    				    <fmt:formatNumber type="number" value="${settleItem.payInt}" />
    				</td>
    				<td>
    				     <fmt:formatNumber type="number" value="${settleItem.payOstdAmt}" />
    				</td>
    				<td>
    				     <fmt:formatNumber type="number" value="${settleItem.payRemant}" />
    				</td>
    			 	
    				<td>
    				     <fmt:formatNumber type="number" value="${settleItem.depositDeductAmt}" />
    				</td>


                <%--
                    <td>${settleItem.arDepositInputAmt}</td>
    			--%>
    				<td>
    				     <fmt:formatNumber type="number" value="${settleItem.otsdAmtAval}" />
    				</td>
    			</tr>
            </c:forEach>
	  	</tbody>

	  	<tfoot>

			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td>合计</td>
				<td style="max-width:100px;">
				  <fmt:formatNumber type="currency" value="${settleRecord.totalPayMoney}" />
				</td>
				
				<%-- <td>${settleRecord.totalArCost}</td> --%>
			
				<td>
					<fmt:formatNumber type="currency" value="${settleRecord.totalPayInt}" />
				</td>
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalPayOstdAmt}" />
				</td>
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalPayRemant}" />
				</td>
				
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalDepositDeductAmt}" />
				</td>

				<%--
				<td>${settleRecord.totalArDepositInputAmt}</td> --%>
			
				<td></td>

			</tr>

	  	</tfoot>

	  </table>

  </div>

  <h4 class="vertical-margin-10">资金清分明细</h4>

  <div class="row">

  	<div class="col-xs-4">
  		
  		<table class="table table-striped demo2do-table bottom-margin-20 text-left settlement">
			
			<tr>
				<td>收款方</td>
				<td>${factoringContract.lenderName}</td>				
			</tr>
				
			<tr>
				<td>利息</td>
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalPayInt}" />
				</td>	
			</tr>
			
			<tr>
				<td>本金</td>
				<td>
				  <fmt:formatNumber type="currency" value="${settleRecord.totalPayOstdAmt}" />
				</td>
			</tr>
      <%-- 
            <tr>
              <td>补充风险准备金</td>
              <td>${settleRecord.totalArDepositInputAmt}</td>
            </tr>
	  --%>			
			<tr>
				<td>合计</td>
				<td>
				    <fmt:formatNumber type="currency" value="${lenderTotal}" />
				</td>
			</tr>

  		</table>

  	</div>

  	<div class="col-xs-4">
  		
  		<table class="table table-striped demo2do-table bottom-margin-20 text-left settlement">
			
			<tr>
				<td>收款方</td>
				<td>${factoringContract.borrowerName}</td>				
			</tr>
		
<%-- 		     		
			<tr>
				<td>释放风险准备金</td>
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalDepositDeductAmt}" />
				</td>	
			</tr>
--%>			
			
			
			<tr>
				<td>尾款</td>
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalPayRemant}" />
				</td>
			</tr>
				
			<tr>
				<td>合计</td>
				<td>
				    <fmt:formatNumber type="currency" value="${borrowerTotal}" />
				</td>
			</tr>

  		</table>

  	</div>


  	<div class="col-xs-4">
  		
  		<table class="table table-striped demo2do-table bottom-margin-20 text-left settlement">
			
		
			<tr>
				<td>释放风险准备金</td>
				<td>
				    <fmt:formatNumber type="currency" value="${settleRecord.totalDepositDeductAmt}"/>
				</td>	
			</tr>

  		</table>

  	</div>


  	
  </div>
   <form action="${ctx}/distribution/settlement/confirm" id="confirmForm">
    <div class="row vertical-margin-20">
 
      <div class="col-xs-4">
        <input type="hidden" name="contractNo" value="${contractNo}">    
        <input type="hidden" name="settleDate" value="${settleDate}">    
        <div class="input-group pull-left">
          <span class="input-group-addon" id="basic-addon1">核销备注</span>
  	      <textarea rows="3" name="comment"></textarea>
        </div>

      </div>
      <div class="col-xs-4">                  
        <div class="btn-group pull-right">
          <button class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" ><i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;确认本次清分</button>
        </div>                
      </div> 
      
      <div class="col-xs-4">                  
        <div class="btn-group pull-right">
          <%-- 
          <a id="print" href="javascript:void(0)" target="_blank" class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" ><i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;打印预览</a>
          --%> 
        </div>                
      </div> 
                     
    </div>
    

  </form>
</div>
<div class="modal fade in bs-example-modal-sm" id="dialog" role="dialog" tabindex="-1" aria-labelledby="dialoglabel" aria-hidden="true">
<div class="modal-dialog">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close close-dialog" aria-label="关闭" ><span aria-hidden="true">&times;</span></button>
			<h4 class="modal-title" id="dialoglabel">提示</h4>
		</div>
		<div class="modal-body">
			<p></p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-default confirm-dialog">确定</button>
			<button type="button" class="btn btn-default close-dialog">关闭</button>
		</div>
	</div>
</div>
</div><!-- dialog end -->

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <script src="${ctx.resource}/js/bootstrap-switch.min.js"></script>
  <script src="${ctx.resource}/js/bootstrap-modal-trigger.js"></script>
  <script src="${ctx.resource}/js/select2.min.js"></script>
  <script src="${ctx.resource}/js/select2_locale_zh-CN.js"></script>
  <script src="${ctx.resource}/js/bootstrap.validate.js"></script>
  <script src="${ctx.resource}/js/bootstrap.validate.en.js"></script>
  <script src="${ctx.resource}/js/bootstrap.validate.trigger.js"></script>
  <script src="${ctx.resource}/js/earth-preupload.js"></script>
  <script src="${ctx.resource}/js/bootstrap-alert-fade-trigger.js"></script>
  <script src="${ctx.resource}/js/bootstrap-datetimepicker.min.js"></script>
  <script src="${ctx.resource}/js/bootstrap-datetimepicker.zh-CN.js"></script>
  <script>
		$("#confirmForm").submit(function(event){
			
			event.preventDefault();
			
			 $('#dialog').find('p').text("确认要清分？").end().modal();
			 
 			 $('#dialog .close-dialog').click(function(){
				 
				 $('#dialog').modal('hide');
				 
				 return false;
			
			 });
 			 $("#dialog .confirm-dialog").click(function(){
 				 
 				$('#dialog').modal('hide');
 				 
 				$("form").submit();
 				 
 			 });
		});
	</script>
